﻿@{
    ViewBag.Title = "Management";
    Layout = "~/Views/Shared/ListLayout.cshtml";
}
<!--layout-->
<table id="dg" class="easyui-datagrid" data-options="title:'在线用户列表',fitColumns:true,pagination:true,fit:true,url:'@Url.Action("GetPagedList")',toolbar:'#tb'">
    <thead>
        <tr>
            <th data-options="checkbox:true"></th>
            <th data-options="field:'FullName',width:100">姓名</th>
            <th data-options="field:'LoginTime',width:100,formatter:common.datetimeFormatter">登陆时间</th>
            <th data-options="field:'IPAddress',width:100">登陆IP</th>
        </tr>
    </thead>
</table>
<!--/layout-->
<!--toolbar-->
<div id="tb">
    <div class="datagrid-toolbar-toolField">
        <div style="width: 70%; float: left">
            @*<a href="#" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="forceOut()">强制退出</a>*@
            @Html.Action("RenderToolbar", "Common", new { area = "" })
        </div>
        <div style="width: 30%; float: left;text-align:right">
            <a id="btnCollapse" href="#" class="easyui-linkbutton" iconcls="icon-collapse" plain="true"></a>
        </div>
    </div>
    <div id="pnlSearch" class="datagrid-toolbar-searchField">
        <form id="formSearch">
            姓名:<input type="text" id="serhFullName" name="serhFullName" data-query="method:'Contains',name:'FullName'" placeholder="姓名" />
        </form>
    </div>
</div>
<!--/toolbar-->
@section Script{
    <script src="~/Scripts/jquery-easyui/src/jquery.datagrid.js"></script>
    <script src="~/Scripts/jquery-easyui/src/jquery.datebox.js"></script>
    <script>

        $(function () {
            $('#btnCollapse').click(function () {
                $('#pnlSearch').toggle();
                $('#dg').datagrid('resize');
                var $collapse = $(this).find('.l-btn-text span:first');
                if ($collapse.hasClass('icon-collapse')) {
                    $collapse.removeClass('icon-collapse').addClass('icon-expand');
                } else {
                    $collapse.removeClass('icon-expand').addClass('icon-collapse');
                }
            });
        });

        /*查询*/
        function dgSearch() {
            var fullName = $('#serhFullName').val();
            var queryParams = {
                fullName: fullName
            };
            $('#dg').datagrid({
                queryParams: queryParams
            });
        }

        //强制退出
        function forceOut() {
            var sessionIDs = [];
            var checkedRows = $('#dg').datagrid('getChecked');
            if (checkedRows.length == 0) {
                top.showAlert('请选择信息!', 'warning');
                return false;
            }

            for (var i = 0; i < checkedRows.length; i++) {
                sessionIDs.push(checkedRows[i].SessionID);
            }

            var url = '@Url.Action("ForceQuit")';
            var postData = sessionIDs;
            common.post(url, postData, function (result) {
                if (result) {
                    $("#dg").datagrid('reload');
                }
            });

        }

    </script>
}



